#!/usr/env/bin python
# -*- coding: utf-8 -*-

# @Time    : 2020-10-28 9:46 上午
# @Author  : yangdy
# @File    : 2020-10-28.1.IP地址
# @Software: PyCharmCE
from tools.my_methods import *


class Solution:
    def restoreIpAddresses(self, s: str) -> List[str]:
        ans = []

        def dfs(ss, i=0, a=[]):
            print(ss, i, a)
            if i >= 4:
                if i == 4 and not ss:
                    ans.append('.'.join(map(lambda x: str(x), a)))
                return
            e = 0
            for si in range(len(ss)):
                if si > 0 and e == 0:
                    continue
                e = e * 10 + ord(ss[si]) - ord('0')
                if e > 255:
                    break
                dfs(ss[si+1:], i+1, a + [e])
        dfs(s)
        return ans


questions = [
    ('25525511135',)
]

work(questions, lambda q: Solution().restoreIpAddresses(q[0]))
